package com.hkts.management.locationInfo.controller;


import com.hkts.management.common.utils.Result;
import com.hkts.management.common.utils.ResultUtil;
import com.hkts.management.utils.AddressUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author yck
 */
@Slf4j
@RestController
@Api(tags = "所在城市管理接口")
@RequestMapping("/order/locationInfo")
@Transactional
public class LocationInfoController {

    @GetMapping(value = "/getAddress")
    @ApiOperation(value = "根据经纬度获取地址信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "localLon", value = "经度", dataType = "String",required = true),
            @ApiImplicitParam(name = "localLat", value = "纬度", dataType = "String",required = true)
    })
    public Result<Object> getAddress(String localLon, String localLat) {
        try {
            return AddressUtils.getAmapByLngAndLat(localLon,localLat);
        }catch (Exception e){
            return ResultUtil.error("获取位置信息失败");
        }
    }
}
